<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.List"%>
<%@page import="com.solution.model.QuestionType"%>
<%@page import="com.solution.model.AnswerType"%>
<%@page import="com.solution.constant.LoginConstants"%>

<% List<QuestionType> questionTypeList= (List<QuestionType>)session.getAttribute(LoginConstants.EXAMINEE_QUESTIONS); 
Integer index = (Integer)session.getAttribute(LoginConstants.EXAMINEE_QUESTION_INDEX);
QuestionType questionType = questionTypeList.get(index);
HashMap<Long,Long> queAnswer = (HashMap<Long,Long>)session.getAttribute(LoginConstants.EXAMINEE_QUESTION_ANSWER);
%>

<table width="650px" border="0" align="center" cellpadding="0" cellspacing="0" class="tbletext">
		<tr>
			<td  align="right" colspan="3"><input type="button" class="imageButton" value="Finish" onClick="finishExamPopup();"></td>						
		</tr>
		<tr>
			<td colspan="3">
			<table>
			<tr>
				<td >Total Question: <b><%=questionTypeList.size()%></b></td>
			</tr>
			<tr>
				<td >Attempted: <b><%=queAnswer.size()%></b></td>
			</tr>
			<tr>
				<td >Attempting: <b><%=(index+1)%></b> of<b> <%=questionTypeList.size()%></b> </td>
			</tr>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="3"></td>
		</tr>
		<tr>
			<td colspan="3" valign="top"  bgcolor="#CCCCCC"><img src="images/zero.gif" width="1" height="1" /></td>
		</tr>
		<tr>
			<td colspan="3"></td>
		</tr>
		<tr>
			<td colspan="3">
			<table>
					<tr>
						<td  style="width:20px;">Q<%=(index+1)%>.</td>
						<td align="left" valign="top" colspan="2"><%=questionType.getQuestionStatement() %></td>			
						
					</tr>
					
					<tr>
						<td style="width:20px;"></td>			
						<td align="left" valign="top" colspan="2">
						<%if(questionType.getImageType()!= null){ %>			
				
						<%String contextPath = session.getAttribute("contextPath").toString();%>
						<img src='<%=contextPath+"/image?imageType=large&image_id="%><%=questionType.getImageType().getId() %>'
						alt="No Image Present">
						<%} %>			
						</td>
					</tr>
					<logic:iterate name="examineeForm" property="answerTypeList" id="answerType">
					<tr >
						<bean:define id="aID" name="answerType" property="id"/>			
						<%if((Long)queAnswer.get(questionType.getId())!= null)	{%>
						<%if(aID.equals((Long)queAnswer.get(questionType.getId()))){%>
						<td style="width:20px;"><input type="radio" name="answerId" id="answerId" value="<%=String.valueOf(aID)%>" checked="checked"></td>			
						<%} else{ %>			
						<td style="width:20px;"><input type="radio" name="answerId" id="answerId" value="<%=String.valueOf(aID)%>" ></td>
						<%} %>
						<%} else{%>
						<td style="width:20px;"><input type="radio" name="answerId" id="answerId" value="<%=String.valueOf(aID)%>" ></td>
						
						<%} %>			
						
						<td align="left"><bean:write name="answerType" property="answerValue"/></td>
						<td align="left"><%if(((AnswerType)answerType).getImageType()!= null) {%>
						<%String contextPath = session.getAttribute("contextPath").toString();%>
						<img src='<%=contextPath+"/image?imageType=large&image_id="%><%=((AnswerType)answerType).getImageType().getId() %>'
						alt="No Image Present">
						<%}else{%>
						&nbsp;
						<%}%>
						</td>
							
						
						
					</tr>
					</logic:iterate>
					<tr>
						<td align="left" valign="top" colspan="3"></td>			
						
					</tr>
					<tr>
						<td style="width:20px;"></td>
						<td align="left" valign="top" colspan="2"><%if(index>0){%><input type="button" class="imageButton" value="Previous" onClick="javascript:prevQuestion()"><%}%>			
						
						<%if(index<questionTypeList.size()-1){%><input type="button" class="imageButton" value="Next" onClick="javascript:nextQuestion()"><%}%> <input type="button" class="imageButton" value="Reset" onClick="javascript:resetQuestion()"></td>			
					</tr>
					</table>
			</td>
		</tr>
    </table>

	
